using System;
using System.Collections.Generic;
using System.Text;

namespace Eve.Data
{
    public class CorporationDivision : EveAssociation<Corporation, Division>
    {
        private int divisionNumber;
        private int size;
        private int leaderId;

        private EveObject leader;
        
        public Corporation Corporation
        {
            get { return From; }
        }
        public Division Division
        {
            get { return To; }
        }
        public int DivisionNumber
        {
            get { return divisionNumber; }
        }
        public int Size
        {
            get { return size; }
        }
        public EveObject Leader
        {
            get
            {
                if (leader == null)
                    leader = EveData.GetObject(db, leaderId);
                return leader;
            }
        }

        internal CorporationDivision(DbDataRow dr)
            : base(dr.Database, new Corporation(dr.Database, dr["corporationID"]), new Division(dr.Database, dr["divisionID"]))
        {
            Fill(dr);
        }
        internal CorporationDivision(DbDataRow dr, Corporation corp)
            : base(dr.Database, corp, new Division(dr.Database, dr["divisionID"]))
        {
            Fill(dr);
        }

        private void Fill(DbDataRow dr)
        {
            divisionNumber = dr["divisionNumber"];
            size = dr["size"];
            leaderId = dr["leaderID"];
        }
    }
}
